/**
 * 
 */
package nl.boektrust.btsoep.shared.model;

import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.googlecode.objectify.annotation.Serialized;

/**
 * @author rao3
 *
 */
public class ISBNReference implements Serializable,IsSerializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8407080678966391012L;
	@Serialized private ISBN isbn;
	private ISBNReferenceType isbnReferenceType;


	public ISBNReference(String isbnArg, ISBNReferenceType isbnReferenceType) {
		super();
		this.isbnReferenceType = isbnReferenceType;
		try {
			if (isbnArg != null) this.isbn.setIsbn12(isbnArg);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public ISBNReference(String isbn) {
		this(isbn, ISBNReferenceType.UNDEFINED);
	}

	public ISBNReference()  {
		this(null);
	}

	/**
	 * @return the isbn
	 */
	public ISBN getIsbn() {
		return isbn;
	}

	/**
	 * @param isbn the isbn to set
	 */
	public void setIsbn(ISBN isbn) {
		this.isbn = isbn;
	}

	/**
	 * @return the isbnReferenceType
	 */
	public ISBNReferenceType getIsbnReferenceType() {
		return isbnReferenceType;
	}

	/**
	 * @param isbnReferenceType the isbnReferenceType to set
	 */
	public void setIsbnReferenceType(ISBNReferenceType isbnReferenceType) {
		this.isbnReferenceType = isbnReferenceType;
	}
	
	public String print() {
		String string;
		if (isbn != null) {
			string = new String("ISBNReference:print(): isbnReferenceType: "+ISBNReferenceType.stringValue(isbnReferenceType)+" isbn.isbn12: "+isbn.getIsbn12());
		} else {
			string = new String("ISBNReference:print(): isbnReferenceType: "+ISBNReferenceType.stringValue(isbnReferenceType)+" isbn13: NULL");

		}
		return string;
	}
	
}
